﻿'Params
'artist (Required (unless mbid)] : The artist name
'mbid (Optional) : The musicbrainz id for the artist
'limit (Optional) : The number of results to fetch per page. Defaults to 50.
'autocorrect[0|1] (Optional) : Transform misspelled artist names into correct artist names, returning the correct version instead. The corrected artist name will be returned in the response.
'page (Optional) : The page number to fetch. Defaults to first page.
'api_key (Required) : A Last.fm API key.

'Auth
' This service does not require authentication. 

Public Structure AlbumGetShoutsResponse
	Dim shouts() As Shout

End Structure

Public Class AlbumGetShouts
	Inherits BaseRequest
	Dim artist As String = ""
	Dim album As String = ""
	Dim mbid As String = ""
	Dim limit As String = ""
	Dim autocorrect As String = ""
	Dim page As String = ""

	Public xmlresponse As XDocument = Nothing

	Public Sub New(album As String, artist As String, mbid As String, autocorrect As String, limit As String, page As String)
		Me.artist = artist
		Me.album = album
		Me.mbid = mbid
		Me.autocorrect = autocorrect
		Me.limit = limit
		Me.page = page
	End Sub

	Public Sub sendRequest()
		ClearMembers()

		AddMember("method", "album.getShouts")
		AddMember("artist", artist, String.IsNullOrEmpty(mbid))
		AddMember("album", Album, String.IsNullOrEmpty(mbid))
		AddMember("mbid", mbid, False)
		AddMember("autocorrect", autocorrect, False)
		AddMember("limit", limit, False)
		AddMember("page", page, False)
		AddMember("api_key", My.Settings.api_key, False)

		xmlresponse = sendPOSTResponse()
	End Sub

	Public Function getResponse() As AlbumGetShoutsResponse
		Dim response As AlbumGetShoutsResponse = Nothing
		Dim count As Integer
		Try
			count = xmlresponse.<lfm>.<shouts>.<shout>.Count()
		Catch ex As Exception
			Return response
		End Try
		If (count > 0) Then
			ReDim response.shouts(count - 1)
			For i As Integer = 0 To count - 1
				response.shouts(i) = New Shout(xmlresponse.<lfm>.<shouts>.<shout>(i))
			Next
		End If
		Return response
	End Function

End Class
